package cn.wolfcode.wolf2w.redis.util;

import cn.wolfcode.wolf2w.util.Consts;
import lombok.Getter;

/**
 * redis操作key统一管理工具类
 * 约定:一个key对应一个枚举实例
 * 1.key的维护
 * 2.key有效性维护
 * RedisKeys
 */
@Getter
public enum RedisKeys {

    //游记点赞
    TRAVEL_THUMB("travel_thumb",-1L),
    //攻略点赞
    STRATEGY_THUMB("strategy_thumb",-1L),
    //攻略收藏
    USER_STRATEGY_FAVOR("user_strategy_favor",-1L),
    //攻略VO
    STRATEGY_STATIS_VO("strategy_statis_vo",-1L),
    //游记VO
    TRAVEL_STATIS_VO("strategy_statis_vo",-1L),
    //存入注册验证码操作
    VERIFY_CODE("verify_code", Consts.VERIFY_CODE_VAI_TIME * 60L),
    //存入用户信息
    USER_TOKEN("user_token", Consts.USER_INFO_TOKEN_VAI_TIME * 60L);

    //key的前缀
    private String perfix;
    //约定时间单位是秒
    private Long time;

    private RedisKeys(String perfix, Long time) {
        this.perfix = perfix;
        this.time = time;

    }

    public String join(String... values) {
        StringBuilder sb = new StringBuilder();
        sb.append(this.perfix);
        for (String value : values) {
            sb.append(":").append(value);
        }
        return sb.toString();
    }
    public static void main(String[] args) {
        System.out.println(RedisKeys.VERIFY_CODE.join("17800000004"));
    }

}
